package cn.ac.siom.query.dao.impl;

import cn.ac.siom.query.dao.ITab_orgDAO;
import cn.ac.siom.query.vo.Tab_org;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Repository
public class Tab_orgDAOImpl extends SqlSessionDaoSupport implements ITab_orgDAO {

    @Override
    public List<Map> findAllParams(Map params) throws Exception {
        return super.getSqlSession().selectList("Tab_orgNS.findAllParams",params);
    }

    @Autowired
    public Tab_orgDAOImpl(SqlSessionFactory sqlSessionFactory){
        super.setSqlSessionFactory(sqlSessionFactory);
    }

    @Override
    public boolean doCreate(Tab_org vo) throws SQLException {
        return false;
    }

    @Override
    public boolean doUpdate(Tab_org vo) throws SQLException {
        return false;
    }

    @Override
    public boolean doRemove(Set<?> ids) throws SQLException {
        return false;
    }

    @Override
    public Tab_org findById(Integer id) throws SQLException {
        return null;
    }

    @Override
    public List<Tab_org> findAll() throws SQLException {
        return super.getSqlSession().selectList("Tab_orgNS.findAll");
    }

    @Override
    public List<Tab_org> findAllBySplit(String column, String keyWord, Integer currentPage, Integer lineSize) throws SQLException {
        return null;
    }

    @Override
    public List<Tab_org> findNo(Integer id) throws SQLException {
        Map<String, Integer> map= new HashMap<>();
        map.put("i_id",id);
        return super.getSqlSession().selectList("Tab_orgNS.findNo", map);
    }
    @Override
    public List<Tab_org> findPage(Integer rownum, Integer page_id) throws SQLException {
        page_id=rownum*(page_id-1);
        Map<String, Integer> map= new HashMap<>();
        map.put("page_id",page_id);
        map.put("rownum",rownum);
        return super.getSqlSession().selectList("Tab_orgNS.findPage", map);
    }

    @Override
    public Integer findCount() throws SQLException {
        return super.getSqlSession().selectOne("Tab_orgNS.findCount");
    }

    @Override
    public String find_Http(Integer i_id) throws SQLException {
        Map<String, Integer> map= new HashMap<>();
        map.put("i_id",i_id);
        return super.getSqlSession().selectOne("Tab_orgNS.findHttp",map);
    }
}
